<?php

namespace libs\mvc;

abstract class Controller {

    protected $_template;
    protected $_templateFile = 'index.php';
    protected $_templateInitialized = false;

    protected function _initTemplate() {
        if (!$this->_templateInitialized) {
            $this->_template = new \libs\mvc\Template();
            $this->_templateInitialized = true;
        }
    }

    public function getTemplate() {
        if (!$this->_templateInitialized)
            $this->_initTemplate();

        return $this->_template;
    }

    public function setTemplateFile($tplFile) {
        $this->_templateFile = $tplFile;
    }

    public function getTemplateFile() {
        return $this->_templateFile;
    }

    public function display() {
        if (!$this->_templateInitialized)
            $this->_initTemplate();

        $this->_template->getContent($this->_templateFile);
    }

}

?>
